package com.cyzy.domain.dto;

import com.cyzy.domain.bean.TUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回前端的格式
 *
 * @author Honarly
 * @date 2024.10.16
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseData {
    private Integer code;
    private String message;
    private Object data;
    private Integer total;

    public static ResponseData success() {
        return new ResponseData(0, "success", null, 0);
    }

    public static ResponseData success(String message) {
        return new ResponseData(0, message, null, 0);
    }

    public static ResponseData success(String message, Object data, Integer total) {
        return new ResponseData(0, message, data, total);
    }


    public static ResponseData error(String message) {
        return new ResponseData(-1, message, null, 0);
    }


    public static ResponseData error(Integer code, String message) {
        return new ResponseData(code, message, null, 0);
    }

    public static ResponseData success(String message,Object data ) {
        return new ResponseData(0, message, data, 0);
    }
}
